package com.javatom.notes.seata.xa.account;

import com.javatom.notes.seata.xa.account.pojo.AccountPojo;
import com.javatom.notes.seata.xa.account.service.AccountService;
import com.javatom.notes.seata.xa.account.service.OrderService;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.boot.ApplicationArguments;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;

/**
 * @description:
 * @author: 曾维录
 * @time: 2019/8/19 18:25
 */
@Controller
public class TestContrllor {

    @Resource
    private AccountService accountService;
    @Resource
    private OrderService orderService;

    @GlobalTransactional(name = "javatom-test",rollbackFor = Exception.class)
    @GetMapping("/test")
    public String  test(){
        AccountPojo a = new AccountPojo();
        a.setAccount("11t11");
        a.setMoney(22);
        accountService.insert(a);
        orderService.insert(222,3);
//       log.error("{}",1/0);
        return "pl";
    }
}
